package com.zcx.qshop.conn;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

@HttpInlet(Conn.INLET_JSON_HOTWORDS)
public class JsonHotwordsAsyGet extends QSAsyGet<JsonHotwordsAsyGet.Info> {
	
	public JsonHotwordsAsyGet(AsyCallBack<Info> asyCallBack) {

		super(asyCallBack);
		
 	}
	
	@Override
	public Info parser(JSONObject object) {
		
		if(object.optString("message").equals("1")){
			
			Info info = new Info();
			
			JSONArray array = object.optJSONArray("wordslist");
			
			for (int i = 0; i < array.length(); i++) {
				
				Info.Word word = new Info.Word();
				
				word.title = array.optJSONObject(i).optString("title"); 
				
				info.words.add(word);
				
			}
			
			return info;
			
		}
		
		return null;
		
	}

	public static class Info{
		
		public List<Word> words = new ArrayList<Word>();
		
		public static class Word{

			public boolean isSelect;

			public String title;
			
		}
		
	}

}
